import javax.swing.JOptionPane;


public class Dynamic {

	public static void main(String[] args){
		int max = 0;
		String tally = "";
		String userInput = JOptionPane.showInputDialog( "Enter a String");
		int [] score = new int[userInput.length()];
		String [] storage = new String[userInput.length()];
		
		
		
			
		char prevChar = 0;
			
			
		
		
	
		for(int i = 1; i < userInput.length(); i++){
			
			
			for(int j = 0; j < i; j++){
				
				
					if(userInput.charAt(i) > userInput.charAt(j) && 
							 prevChar == 0 ){//base case
						storage[i] = tally + userInput.charAt(j) + userInput.charAt(i);
						prevChar = userInput.charAt(i);
										
						System.out.println(storage[i] + "   " +  prevChar + "   " + j + "   " + i + "   first");
						
						}
						
			
				
				else if(prevChar < userInput.charAt(i)){// else 2				
			    storage[i] = storage[i-1] + userInput.charAt(i);
				prevChar = userInput.charAt(i);
				System.out.println(storage[i] + "   " +  prevChar + "   " + 
				userInput.charAt(i) + "   " + j + "   " + i + "      else 2");
				
			 }
				
				else if(prevChar > userInput.charAt(i)){//else 3
					storage[i] = storage[i-1];
					prevChar = userInput.charAt(i);
					System.out.println(storage[i] + "   " +  prevChar + "   " + 
					userInput.charAt(i) + j + "   " + i + "     else 3");					
				 }
				
				
			}
		}
	}
}
		 
			
			
			
			
		
		
		
	


